package cn.botter.wechat.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @BelongsProject: bo-club
 * @BelongsPackage: cn.botter.wechat.handler
 * @Author: 爱写Bug的Botter
 * @CreateTime: 2025-03-21:22:25
 * @Description: 描述
 * @Version: 1.0
 */
@Component
@Slf4j
public class SubscribeMsgHandler implements WeChatMsgHandler {

    @Override
    public WeChatMsgTypeEnum getMsgType() {
        return WeChatMsgTypeEnum.SUBSCRIBE;
    }

    @Override
    public String dealMsg(Map<String, String> msgType) {
        log.info("触发用户关注的事件");
        String fromUserName = msgType.get("FromUserName");
        String toUserName = msgType.get("ToUserName");
        String content = "感谢您的关注,我是Botter!";
        String replyContent = "" +
                "<xml><ToUserName><![CDATA["+fromUserName+"]]></ToUserName>\n" +
                "<FromUserName><![CDATA["+toUserName+"]]></FromUserName>\n" +
                "<CreateTime>1742632552</CreateTime>\n" +
                "<MsgType><![CDATA[text]]></MsgType>\n" +
                "<Content><![CDATA["+content+"]]></Content>\n" +
                "<MsgId>24948502409438544</MsgId>\n" +
                "</xml>";
        return replyContent;
    }
}
